#include "ProcessPool.hpp"
#include"Task.hpp" 

void Usage(string proc)
{
        cout<<"Usage:"<<proc<<" process-num"<<endl;
}

//我们自己就是master进程,父写子读。
int main(int argc ,char *argv[])
{
        //1.创建管道
        if(argc != 2)
        {
                Usage(argv[0]);
                return UsageError;
        }
        int num=stoi(argv[1]); //子进程个数
	ProcessPool *pp=new ProcessPool(num,Worker);
	//1.初始化进程池
	pp->InitProcesspol();
	//2.派发任务
	pp->DispatchTasks1();
	//3.退出进程池
	pp->CleanProcessPol();



       	//vector<Channel> channels;//管理子进程
        //1.初始化进程池
      	//InitProcesspol(num,channels,Worker);

        //拿到管理子进程的vector了。
        //DebugPrint(channels);

        //2.轮询派发任务
        //DispatchTasks1(channels);

        //3.退出进程池
        //CleanProcessPol(channels);
	delete pp;
        return 0;
}

